///////////////////////////////////////////////////////////////////////////
//// an object to contain the selection tool used for selecting tabs (with
//// a glow grid of terms
group { name: "terminology/sel/base";
   script {
      public message(Msg_Type:type, id, ...) {
//         new r, g, b, a;
         new v;

         if ((type != MSG_INT) || (id != 1)) return;

         v = (getarg(2) * 255) / 100;

//         custom_state(PART:"shadow", "default", 0.0);
//         get_state_val(PART:"shadow", STATE_COLOR, r, g, b, a);
//         set_state_val(PART:"shadow", STATE_COLOR, r, g, b, v);
//         set_state(PART:"shadow", "custom", 0.0);

         if (v < 255)
           set_state(PART:"fill", "translucent", 0.0);
         else
           set_state(PART:"fill", "default", 0.0);
      }
   }
   parts {
      ////////////////////////////////////////////////////////////////////
      // background and shadows
      part { name: "fill"; type: RECT;
         mouse_events: 0;
         description { state: "default" 0.0;
            color: 32 32 32 255;
         }
         description { state: "translucent" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }

      ////////////////////////////////////////////////////////////////////
      // content (where the grid of terms goes)
      part { name: "clip"; type: RECT;
         description { state: "default" 0.0;
         }
      }
      part { name: "terminology.content"; type: SWALLOW;
         clip_to: "clip";
         description { state: "default" 0.0;
         }
      }

      ////////////////////////////////////////////////////////////////////
      // fancy stuff on top
//      program { signal: "begin"; source: "terminology";
//         action: STATE_SET "visible" 0.0;
//         transition: DECELERATE 0.3;
//         target: "overlay";
//      }
//      program { signal: "end"; source: "terminology";
//         action: STATE_SET "default" 0.0;
//         transition: DECELERATE 0.3 CURRENT;
//         target: "overlay";
//         target: "overlay_shadow";
//      }
   }
}

group { name: "terminology/sel/item";
   images.image: "pm_shadow.png" COMP;
   parts {
      ////////////////////////////////////////////////////////////////////
      // base background and selection image
      part { name: "clip"; type: RECT;
         description { state: "default" 0.0;
            rel.to: "terminology.content";
            color: 192 192 192 255; // no cc
         }
         description { state: "selected" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 255; // no cc
         }
      }
      part { name: "shadow";
         mouse_events: 0;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            rel.to: "terminology.content";
            rel1.offset: -32 -32;
            rel2.offset: 31 31;
            image.normal: "pm_shadow.png";
            image.border: 64 64 64 64;
            image.border_scale_by: 0.5;
            image.border_scale: 1;
            color_class: "/shadow/normal/term/sel/item";
            fill.smooth: 0;
            offscale;
         }
         description { state: "selected" 0.0;
            inherit: "default" 0.0;
            rel1.offset: -64 -64;
            rel2.offset: 63 63;
            image.border_scale_by: 1.0;
            color_class: "/shadow/selected/term/sel/item";
         }
      }

      ////////////////////////////////////////////////////////////////////
      // swallowed terminal content + bg inside it
      part { name: "base"; type: RECT;
         clip_to: "clip";
         description { state: "default" 0.0;
            color_class: "BG";
            rel.to: "terminology.content";
         }
      }
      part { name: "terminology.content"; type: SWALLOW;
         clip_to: "clip";
         description { state: "default" 0.0;
            rel1.relative: 0.1 0.1;
            rel2.relative: 0.9 0.9;
         }
         description { state: "selected" 0.0;
            inherit: "default" 0.0;
            rel1.relative: 0.0 0.0;
            rel2.relative: 1.0 1.0;
         }
      }
      program { signal: "selected"; source: "terminology";
         action: STATE_SET "selected" 0.0;
         transition: DECELERATE 0.2 CURRENT;
         target: "terminology.content";
         target: "terminology.label";
         target: "shadow";
         target: "clip";
      }
      program { signal: "selected,start"; source: "terminology";
         action: STATE_SET "selected" 0.0;
         target: "terminology.content";
         target: "terminology.label";
         target: "shadow";
         target: "clip";
      }
      program { signal: "unselected"; source: "terminology";
         action: STATE_SET "default" 0.0;
         transition: DECELERATE 0.4 CURRENT;
         target: "terminology.content";
         target: "terminology.label";
         target: "shadow";
         target: "clip";
      }

      ////////////////////////////////////////////////////////////////////
      // fancy stuff over the top of the terminal for shading and labelling
      part { name: "terminology.label"; type: TEXT; mouse_events: 0;
         scale: 1;
         description { state: "default" 0.0;
            rel.to: "terminology.content";
            rel1.offset: 4 4;
            rel2.offset: -5 -5;
            offscale;
            color_class: "/fg/normal/term/sel/title/text";
            align: 0.5 0.0;
            text { font: "Sans"; size: 10;
               align: 0.5 0.0;
               min: 0 1;
            }
         }
         description { state: "selected" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/selected/term/sel/title/text";
         }
      }

      ////////////////////////////////////////////////////////////////////
      // visual bell - spinning red siren light
      images.image: "circle-1200.png" COMP;
      images.image: "strobe-600.png" COMP;
      part { name: "bell_glow"; mouse_events: 0;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            visible: 0;
            color: 255 80 60 0; // no cc
            rel.to: "bell";
            min: 100 100;
            image.normal: "circle-1200.png";
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            color: 255 80 60 32;
         }
      }
      part { name: "bell_glow2"; mouse_events: 0;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            visible: 0;
            color: 255 240 160 0; // no cc
            rel.to: "bell";
            min: 50 50;
            image.normal: "circle-1200.png";
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            color: 255 220 120 32;
         }
      }
      part { name: "bell_strobe";
         mouse_events: 0;
         description { state: "default" 0.0;
            fixed: 1 1;
            color: 255 255 200 255;
            rel.to: "bell_glow2";
            image.normal: "strobe-600.png";
            rel1.relative: -0.5 -0.5;
            rel2.relative: 1.5 1.5;
            map {
               on: 1;
               smooth: 1;
               rotation.center: "bell";
            }
            visible: 0;
         }
         description { state: "spin" 0.0;
            inherit: "default" 0.0;
            map.rotation.z: 0.0;
            visible: 1;
         }
         description { state: "spin_done" 0.0;
            inherit: "default" 0.0;
            map.rotation.z: 720.0;
            visible: 1;
         }
      }
      part { name: "bell";
         mouse_events: 0;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            visible: 0;
            color: 255 255 255 0;
            max: 20 20;
            min: 20 20;
            align: 1.0 1.0;
            rel1.offset: 15 15;
            rel2.offset: -16 -16;
            rel.to: "terminology.content";
            image.normal: "circle-1200.png";
            offscale;
         }
         description { state: "visible" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            color: 255 255 255 255;
         }
      }
      program { signal: "bell"; source: "terminology";
         action: STATE_SET "visible" 0.0;
         target: "bell";
         target: "bell_glow";
         target: "bell_glow2";
         after: "bell3";
      }
      program { name: "bell3";
         action: STATE_SET "spin" 0.0;
         transition: LINEAR 0.1;
         target: "bell_strobe";
         after: "bell4.1";
      }
      program { name: "bell4.1";
         action: STATE_SET "spin" 0.0;
         target: "bell_strobe";
         after: "bell4.2";
      }
      program { name: "bell4.2";
         action: STATE_SET "spin_done" 0.0;
         transition: LINEAR 0.9;
         target: "bell_strobe";
         after: "bell4.1";
      }
   }
}
